<!DOCTYPE html>
<html lang="en-US">
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width,initial-scale=1">
    <title>应用配置 | Vue.js</title>
    <meta name="generator" content="VuePress 1.8.2">
    <link href="https://fonts.googleapis.com/css?family=Inter:300,400,500,600|Open+Sans:400,600;display=swap" rel="stylesheet">
    <link href="https://stackpath.bootstrapcdn.com/font-awesome/4.7.0/css/font-awesome.min.css" rel="stylesheet">
    <link rel="icon" href="/vue3/logo.png">
    <link rel="manifest" href="/vue3/manifest.json">
    <link rel="apple-touch-icon" href="/images/icons/apple-icon-152x152.png">
    <script src="https://player.youku.com/iframeapi"></script>
    <meta name="description" content="Vue.js - The 渐进式 JavaScript 框架">
    <meta name="theme-color" content="#3eaf7c">
    <meta name="apple-mobile-web-app-capable" content="yes">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta name="apple-mobile-web-app-status-bar-style" content="black">
    <meta name="msapplication-TileImage" content="/images/icons/ms-icon-144x144.png">
    <meta name="msapplication-TileColor" content="#000000">
    
    <link rel="preload" href="/vue3/assets/css/0.styles.9bf58a16.css" as="style"><link rel="preload" href="/vue3/assets/js/app.9f011487.js" as="script"><link rel="preload" href="/vue3/assets/js/11.bea13863.js" as="script"><link rel="preload" href="/vue3/assets/js/43.98898a3b.js" as="script"><link rel="preload" href="/vue3/assets/js/32.75be14cd.js" as="script"><link rel="preload" href="/vue3/assets/js/23.f23a1976.js" as="script"><link rel="prefetch" href="/vue3/assets/js/1.98516ad1.js"><link rel="prefetch" href="/vue3/assets/js/100.94330a5d.js"><link rel="prefetch" href="/vue3/assets/js/101.560a6b49.js"><link rel="prefetch" href="/vue3/assets/js/102.f12c4d91.js"><link rel="prefetch" href="/vue3/assets/js/103.be709996.js"><link rel="prefetch" href="/vue3/assets/js/104.49fdebb1.js"><link rel="prefetch" href="/vue3/assets/js/105.df17d42d.js"><link rel="prefetch" href="/vue3/assets/js/106.fa0a51b7.js"><link rel="prefetch" href="/vue3/assets/js/107.392361bf.js"><link rel="prefetch" href="/vue3/assets/js/108.af6fc4d6.js"><link rel="prefetch" href="/vue3/assets/js/109.18bcf602.js"><link rel="prefetch" href="/vue3/assets/js/110.052b8c4c.js"><link rel="prefetch" href="/vue3/assets/js/111.528533a3.js"><link rel="prefetch" href="/vue3/assets/js/112.28359168.js"><link rel="prefetch" href="/vue3/assets/js/113.190e7aff.js"><link rel="prefetch" href="/vue3/assets/js/114.dddc32bb.js"><link rel="prefetch" href="/vue3/assets/js/115.7924a11d.js"><link rel="prefetch" href="/vue3/assets/js/116.5836841c.js"><link rel="prefetch" href="/vue3/assets/js/117.1e3523ad.js"><link rel="prefetch" href="/vue3/assets/js/118.fda02ea3.js"><link rel="prefetch" href="/vue3/assets/js/119.c56ed999.js"><link rel="prefetch" href="/vue3/assets/js/12.11fdef37.js"><link rel="prefetch" href="/vue3/assets/js/120.14653326.js"><link rel="prefetch" href="/vue3/assets/js/121.5bdc69d1.js"><link rel="prefetch" href="/vue3/assets/js/122.ea246bef.js"><link rel="prefetch" href="/vue3/assets/js/123.1a041b0d.js"><link rel="prefetch" href="/vue3/assets/js/124.4849397b.js"><link rel="prefetch" href="/vue3/assets/js/125.f8a4d9a1.js"><link rel="prefetch" href="/vue3/assets/js/126.e6f8c88f.js"><link rel="prefetch" href="/vue3/assets/js/127.bb0d0c14.js"><link rel="prefetch" href="/vue3/assets/js/128.6fcdf065.js"><link rel="prefetch" href="/vue3/assets/js/129.d37419cf.js"><link rel="prefetch" href="/vue3/assets/js/13.84b5a427.js"><link rel="prefetch" href="/vue3/assets/js/130.2ff76428.js"><link rel="prefetch" href="/vue3/assets/js/131.dbd74031.js"><link rel="prefetch" href="/vue3/assets/js/132.b4ca1a54.js"><link rel="prefetch" href="/vue3/assets/js/133.95a81c57.js"><link rel="prefetch" href="/vue3/assets/js/134.da6a25f1.js"><link rel="prefetch" href="/vue3/assets/js/135.46cd4ce4.js"><link rel="prefetch" href="/vue3/assets/js/136.c908c444.js"><link rel="prefetch" href="/vue3/assets/js/137.838c736d.js"><link rel="prefetch" href="/vue3/assets/js/138.5f56ac41.js"><link rel="prefetch" href="/vue3/assets/js/139.2d3218e7.js"><link rel="prefetch" href="/vue3/assets/js/14.ccde2ff7.js"><link rel="prefetch" href="/vue3/assets/js/140.73a6c08b.js"><link rel="prefetch" href="/vue3/assets/js/141.e6e97fa2.js"><link rel="prefetch" href="/vue3/assets/js/142.78b66660.js"><link rel="prefetch" href="/vue3/assets/js/143.18a5f522.js"><link rel="prefetch" href="/vue3/assets/js/144.007967ab.js"><link rel="prefetch" href="/vue3/assets/js/145.69c6c622.js"><link rel="prefetch" href="/vue3/assets/js/146.5eb14458.js"><link rel="prefetch" href="/vue3/assets/js/147.01b7b88c.js"><link rel="prefetch" href="/vue3/assets/js/148.c4464ffa.js"><link rel="prefetch" href="/vue3/assets/js/149.66883751.js"><link rel="prefetch" href="/vue3/assets/js/15.6957b547.js"><link rel="prefetch" href="/vue3/assets/js/150.03ccd0c3.js"><link rel="prefetch" href="/vue3/assets/js/151.5cb25376.js"><link rel="prefetch" href="/vue3/assets/js/152.51fa843b.js"><link rel="prefetch" href="/vue3/assets/js/153.c280bbfc.js"><link rel="prefetch" href="/vue3/assets/js/154.3c1208bb.js"><link rel="prefetch" href="/vue3/assets/js/155.f2bec114.js"><link rel="prefetch" href="/vue3/assets/js/156.9d563e5f.js"><link rel="prefetch" href="/vue3/assets/js/157.09a62483.js"><link rel="prefetch" href="/vue3/assets/js/158.e8ee954d.js"><link rel="prefetch" href="/vue3/assets/js/159.806c0da5.js"><link rel="prefetch" href="/vue3/assets/js/16.1c3a9fe2.js"><link rel="prefetch" href="/vue3/assets/js/160.70fe7ee3.js"><link rel="prefetch" href="/vue3/assets/js/161.7b67e86f.js"><link rel="prefetch" href="/vue3/assets/js/162.d2cb71f8.js"><link rel="prefetch" href="/vue3/assets/js/163.c2f8c96a.js"><link rel="prefetch" href="/vue3/assets/js/164.c0ce5d22.js"><link rel="prefetch" href="/vue3/assets/js/165.dd31fc10.js"><link rel="prefetch" href="/vue3/assets/js/166.861df1bd.js"><link rel="prefetch" href="/vue3/assets/js/167.8cade3be.js"><link rel="prefetch" href="/vue3/assets/js/168.d384c54a.js"><link rel="prefetch" href="/vue3/assets/js/169.266b17c8.js"><link rel="prefetch" href="/vue3/assets/js/17.13ae2912.js"><link rel="prefetch" href="/vue3/assets/js/170.8da5cca1.js"><link rel="prefetch" href="/vue3/assets/js/171.59233d62.js"><link rel="prefetch" href="/vue3/assets/js/172.e2ff7db9.js"><link rel="prefetch" href="/vue3/assets/js/173.4fae5fdf.js"><link rel="prefetch" href="/vue3/assets/js/174.25d65654.js"><link rel="prefetch" href="/vue3/assets/js/175.0fd8e932.js"><link rel="prefetch" href="/vue3/assets/js/176.afbb20d7.js"><link rel="prefetch" href="/vue3/assets/js/177.3fce4ef4.js"><link rel="prefetch" href="/vue3/assets/js/178.a69eab8f.js"><link rel="prefetch" href="/vue3/assets/js/179.b9c69246.js"><link rel="prefetch" href="/vue3/assets/js/18.2176f64f.js"><link rel="prefetch" href="/vue3/assets/js/180.80eaf61f.js"><link rel="prefetch" href="/vue3/assets/js/181.8c9ea68f.js"><link rel="prefetch" href="/vue3/assets/js/182.363237b2.js"><link rel="prefetch" href="/vue3/assets/js/183.1bcce34d.js"><link rel="prefetch" href="/vue3/assets/js/184.63965c38.js"><link rel="prefetch" href="/vue3/assets/js/185.145d17f7.js"><link rel="prefetch" href="/vue3/assets/js/186.01c28041.js"><link rel="prefetch" href="/vue3/assets/js/187.651fc5e1.js"><link rel="prefetch" href="/vue3/assets/js/188.371a53d8.js"><link rel="prefetch" href="/vue3/assets/js/189.21a8c4f3.js"><link rel="prefetch" href="/vue3/assets/js/19.f35e6099.js"><link rel="prefetch" href="/vue3/assets/js/2.655ed906.js"><link rel="prefetch" href="/vue3/assets/js/20.6a9108db.js"><link rel="prefetch" href="/vue3/assets/js/21.b90deaac.js"><link rel="prefetch" href="/vue3/assets/js/22.2da4161c.js"><link rel="prefetch" href="/vue3/assets/js/24.0f4c4cde.js"><link rel="prefetch" href="/vue3/assets/js/25.3a155505.js"><link rel="prefetch" href="/vue3/assets/js/26.d7a45b3e.js"><link rel="prefetch" href="/vue3/assets/js/27.3c237b85.js"><link rel="prefetch" href="/vue3/assets/js/28.1722182e.js"><link rel="prefetch" href="/vue3/assets/js/29.158159ee.js"><link rel="prefetch" href="/vue3/assets/js/3.9e67029d.js"><link rel="prefetch" href="/vue3/assets/js/30.085c3faf.js"><link rel="prefetch" href="/vue3/assets/js/31.d95eaf7d.js"><link rel="prefetch" href="/vue3/assets/js/33.b9adbce6.js"><link rel="prefetch" href="/vue3/assets/js/34.ef96058c.js"><link rel="prefetch" href="/vue3/assets/js/35.f2d110b9.js"><link rel="prefetch" href="/vue3/assets/js/36.11e69166.js"><link rel="prefetch" href="/vue3/assets/js/37.d51d98ce.js"><link rel="prefetch" href="/vue3/assets/js/38.ba303c3e.js"><link rel="prefetch" href="/vue3/assets/js/39.7af701c4.js"><link rel="prefetch" href="/vue3/assets/js/4.2768033f.js"><link rel="prefetch" href="/vue3/assets/js/40.50b39df3.js"><link rel="prefetch" href="/vue3/assets/js/41.377521c6.js"><link rel="prefetch" href="/vue3/assets/js/42.3b63f9c9.js"><link rel="prefetch" href="/vue3/assets/js/44.29a6e6a2.js"><link rel="prefetch" href="/vue3/assets/js/45.7d0883fe.js"><link rel="prefetch" href="/vue3/assets/js/46.4e93f7dd.js"><link rel="prefetch" href="/vue3/assets/js/47.4c629b92.js"><link rel="prefetch" href="/vue3/assets/js/48.f1bf29a9.js"><link rel="prefetch" href="/vue3/assets/js/49.a49482a4.js"><link rel="prefetch" href="/vue3/assets/js/5.175dbe8f.js"><link rel="prefetch" href="/vue3/assets/js/50.dbad5716.js"><link rel="prefetch" href="/vue3/assets/js/51.76b7354d.js"><link rel="prefetch" href="/vue3/assets/js/52.3a1a9a63.js"><link rel="prefetch" href="/vue3/assets/js/53.be592e24.js"><link rel="prefetch" href="/vue3/assets/js/54.d97c6e79.js"><link rel="prefetch" href="/vue3/assets/js/55.eff64da2.js"><link rel="prefetch" href="/vue3/assets/js/56.e3dc0e44.js"><link rel="prefetch" href="/vue3/assets/js/57.d7b38bdd.js"><link rel="prefetch" href="/vue3/assets/js/58.fdc076c9.js"><link rel="prefetch" href="/vue3/assets/js/59.9f11e0ea.js"><link rel="prefetch" href="/vue3/assets/js/6.c6369861.js"><link rel="prefetch" href="/vue3/assets/js/60.a818862d.js"><link rel="prefetch" href="/vue3/assets/js/61.bb9ab96c.js"><link rel="prefetch" href="/vue3/assets/js/62.116aefff.js"><link rel="prefetch" href="/vue3/assets/js/63.be6c07d0.js"><link rel="prefetch" href="/vue3/assets/js/64.0ad95216.js"><link rel="prefetch" href="/vue3/assets/js/65.f8749c54.js"><link rel="prefetch" href="/vue3/assets/js/66.7680f482.js"><link rel="prefetch" href="/vue3/assets/js/67.6fba4d5a.js"><link rel="prefetch" href="/vue3/assets/js/68.ed63b04b.js"><link rel="prefetch" href="/vue3/assets/js/69.73b3bf13.js"><link rel="prefetch" href="/vue3/assets/js/7.cd1985fe.js"><link rel="prefetch" href="/vue3/assets/js/70.6e7dc295.js"><link rel="prefetch" href="/vue3/assets/js/71.32c17a2a.js"><link rel="prefetch" href="/vue3/assets/js/72.ab8b426d.js"><link rel="prefetch" href="/vue3/assets/js/73.73838f6c.js"><link rel="prefetch" href="/vue3/assets/js/74.c3c5f3e6.js"><link rel="prefetch" href="/vue3/assets/js/75.5f63164c.js"><link rel="prefetch" href="/vue3/assets/js/76.6071fb5c.js"><link rel="prefetch" href="/vue3/assets/js/77.1f274f68.js"><link rel="prefetch" href="/vue3/assets/js/78.16d4c50b.js"><link rel="prefetch" href="/vue3/assets/js/79.fc2b2e03.js"><link rel="prefetch" href="/vue3/assets/js/80.42173ce4.js"><link rel="prefetch" href="/vue3/assets/js/81.51405a99.js"><link rel="prefetch" href="/vue3/assets/js/82.be2d0e4f.js"><link rel="prefetch" href="/vue3/assets/js/83.75b4d2af.js"><link rel="prefetch" href="/vue3/assets/js/84.fbaa5717.js"><link rel="prefetch" href="/vue3/assets/js/85.60063971.js"><link rel="prefetch" href="/vue3/assets/js/86.cf80c75d.js"><link rel="prefetch" href="/vue3/assets/js/87.eca6cea7.js"><link rel="prefetch" href="/vue3/assets/js/88.3967efe4.js"><link rel="prefetch" href="/vue3/assets/js/89.bf83cb8c.js"><link rel="prefetch" href="/vue3/assets/js/90.96996b25.js"><link rel="prefetch" href="/vue3/assets/js/91.31b5ee41.js"><link rel="prefetch" href="/vue3/assets/js/92.d197feb2.js"><link rel="prefetch" href="/vue3/assets/js/93.b471c7fe.js"><link rel="prefetch" href="/vue3/assets/js/94.b4298707.js"><link rel="prefetch" href="/vue3/assets/js/95.2f91d14f.js"><link rel="prefetch" href="/vue3/assets/js/96.18b64251.js"><link rel="prefetch" href="/vue3/assets/js/97.363729fa.js"><link rel="prefetch" href="/vue3/assets/js/98.cb8f0be4.js"><link rel="prefetch" href="/vue3/assets/js/99.f62cf45d.js"><link rel="prefetch" href="/vue3/assets/js/vendors~docsearch.5cf23a03.js"><link rel="prefetch" href="/vue3/assets/js/vendors~search-page.d14326ff.js">
    <link rel="stylesheet" href="/vue3/assets/css/0.styles.9bf58a16.css">
  </head>
  <body>
    <div id="app" data-server-rendered="true"><div class="theme-container"><!----> <header class="navbar"><div class="sidebar-button"><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" role="img" viewBox="0 0 448 512" class="icon"><path fill="currentColor" d="M436 124H12c-6.627 0-12-5.373-12-12V80c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12zm0 160H12c-6.627 0-12-5.373-12-12v-32c0-6.627 5.373-12 12-12h424c6.627 0 12 5.373 12 12v32c0 6.627-5.373 12-12 12z"></path></svg></div> <a href="/vue3/" class="home-link router-link-active"><img src="/vue3/logo.png" alt="Vue.js" class="logo"> <span class="site-name can-hide">Vue.js</span></a> <span style="font-size:.9rem;color:#2c3e50;margin-left:20px;">非官方文档，查看官方文档请移步<a href="https://v3.cn.vuejs.org/" target="_blank">这里</a></span> <div class="links"><!----> <nav class="nav-links can-hide"><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="文档菜单" class="dropdown-title"><span class="title">文档</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vue3/guide/introduction.html" class="nav-link">
  教程
</a></li><li class="dropdown-item"><!----> <a href="/vue3/style-guide/" class="nav-link">
  风格指南
</a></li><li class="dropdown-item"><!----> <a href="/vue3/cookbook/" class="nav-link">
  Cookbook
</a></li><li class="dropdown-item"><!----> <a href="/vue3/examples/markdown.html" class="nav-link">
  示例
</a></li><li class="dropdown-item"><!----> <a href="/vue3/guide/contributing/writing-guide.html" class="nav-link">
  贡献文档
</a></li><li class="dropdown-item"><!----> <a href="/vue3/guide/migration/introduction.html" class="nav-link">
  从 Vue 2 迁移
</a></li></ul></div></div><div class="nav-item"><a href="/vue3/api/" class="nav-link router-link-active">
  API 参考
</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="生态系统" class="dropdown-title"><span class="title">生态系统</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>
          社区
        </h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/vue3/community/team/" class="nav-link">
  团队
</a></li><li class="dropdown-subitem"><a href="/vue3/community/partners.html" class="nav-link">
  合作伙伴
</a></li><li class="dropdown-subitem"><a href="/vue3/community/join/" class="nav-link">
  加入
</a></li><li class="dropdown-subitem"><a href="/vue3/community/themes/" class="nav-link">
  主题
</a></li></ul></li><li class="dropdown-item"><h4>
          官方项目
        </h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="https://next.router.vuejs.org/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  Vue Router
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://next.vuex.vuejs.org/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  Vuex
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://cli.vuejs.org/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  Vue CLI
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://next.vue-test-utils.vuejs.org/guide/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  Vue Test Utils
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://devtools.vuejs.org" target="_blank" rel="noopener noreferrer" class="nav-link external">
  Devtools
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://news.vuejs.org/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  Weekly news
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://blog.vuejs.org/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  Blog
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="支持 Vue" class="dropdown-title"><span class="title">支持 Vue</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vue3/support-vuejs/#一次性捐款" class="nav-link">
  一次性捐款
</a></li><li class="dropdown-item"><!----> <a href="/vue3/support-vuejs/#周期性赞助" class="nav-link">
  周期性捐款
</a></li><li class="dropdown-item"><!----> <a href="https://www.smallsticker.com/%E8%B4%B4%E7%BA%B8/vue.html" target="_blank" rel="noopener noreferrer" class="nav-link external">
  贴纸
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-item"><!----> <a href="https://osholic.com/?utm_source=vue&amp;utm_medium=dropdown" target="_blank" rel="noopener noreferrer" class="nav-link external">
  周边
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-item"><!----> <a href="https://vue.threadless.com/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  T-Shirt 商店
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="多语言" class="dropdown-title"><span class="title">多语言</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://v3.vuejs.org/" target="_blank" class="nav-link external">
  English
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-item"><!----> <a href="https://v3.ko.vuejs.org/" target="_blank" class="nav-link external">
  한국어
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-item"><!----> <a href="https://v3.ja.vuejs.org/" target="_blank" class="nav-link external">
  日本語
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-item"><!----> <a href="https://v3.ru.vuejs.org/ru/" target="_blank" class="nav-link external">
  Русский
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-item"><!----> <a href="/vue3/guide/contributing/translations.html#community-translations" class="nav-link">
  更多翻译
</a></li></ul></div></div> <a href="https://github.com/vuejs/docs-next-zh-cn" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav> <div id="docsearch"></div></div></header> <div class="sidebar-mask"></div> <aside class="sidebar"><nav class="nav-links"><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="文档菜单" class="dropdown-title"><span class="title">文档</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vue3/guide/introduction.html" class="nav-link">
  教程
</a></li><li class="dropdown-item"><!----> <a href="/vue3/style-guide/" class="nav-link">
  风格指南
</a></li><li class="dropdown-item"><!----> <a href="/vue3/cookbook/" class="nav-link">
  Cookbook
</a></li><li class="dropdown-item"><!----> <a href="/vue3/examples/markdown.html" class="nav-link">
  示例
</a></li><li class="dropdown-item"><!----> <a href="/vue3/guide/contributing/writing-guide.html" class="nav-link">
  贡献文档
</a></li><li class="dropdown-item"><!----> <a href="/vue3/guide/migration/introduction.html" class="nav-link">
  从 Vue 2 迁移
</a></li></ul></div></div><div class="nav-item"><a href="/vue3/api/" class="nav-link router-link-active">
  API 参考
</a></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="生态系统" class="dropdown-title"><span class="title">生态系统</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><h4>
          社区
        </h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="/vue3/community/team/" class="nav-link">
  团队
</a></li><li class="dropdown-subitem"><a href="/vue3/community/partners.html" class="nav-link">
  合作伙伴
</a></li><li class="dropdown-subitem"><a href="/vue3/community/join/" class="nav-link">
  加入
</a></li><li class="dropdown-subitem"><a href="/vue3/community/themes/" class="nav-link">
  主题
</a></li></ul></li><li class="dropdown-item"><h4>
          官方项目
        </h4> <ul class="dropdown-subitem-wrapper"><li class="dropdown-subitem"><a href="https://next.router.vuejs.org/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  Vue Router
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://next.vuex.vuejs.org/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  Vuex
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://cli.vuejs.org/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  Vue CLI
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://next.vue-test-utils.vuejs.org/guide/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  Vue Test Utils
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://devtools.vuejs.org" target="_blank" rel="noopener noreferrer" class="nav-link external">
  Devtools
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://news.vuejs.org/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  Weekly news
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-subitem"><a href="https://blog.vuejs.org/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  Blog
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="支持 Vue" class="dropdown-title"><span class="title">支持 Vue</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="/vue3/support-vuejs/#一次性捐款" class="nav-link">
  一次性捐款
</a></li><li class="dropdown-item"><!----> <a href="/vue3/support-vuejs/#周期性赞助" class="nav-link">
  周期性捐款
</a></li><li class="dropdown-item"><!----> <a href="https://www.smallsticker.com/%E8%B4%B4%E7%BA%B8/vue.html" target="_blank" rel="noopener noreferrer" class="nav-link external">
  贴纸
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-item"><!----> <a href="https://osholic.com/?utm_source=vue&amp;utm_medium=dropdown" target="_blank" rel="noopener noreferrer" class="nav-link external">
  周边
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-item"><!----> <a href="https://vue.threadless.com/" target="_blank" rel="noopener noreferrer" class="nav-link external">
  T-Shirt 商店
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li></ul></div></div><div class="nav-item"><div class="dropdown-wrapper"><button type="button" aria-label="多语言" class="dropdown-title"><span class="title">多语言</span> <span class="arrow right"></span></button> <ul class="nav-dropdown" style="display:none;"><li class="dropdown-item"><!----> <a href="https://v3.vuejs.org/" target="_blank" class="nav-link external">
  English
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-item"><!----> <a href="https://v3.ko.vuejs.org/" target="_blank" class="nav-link external">
  한국어
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-item"><!----> <a href="https://v3.ja.vuejs.org/" target="_blank" class="nav-link external">
  日本語
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-item"><!----> <a href="https://v3.ru.vuejs.org/ru/" target="_blank" class="nav-link external">
  Русский
  <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></li><li class="dropdown-item"><!----> <a href="/vue3/guide/contributing/translations.html#community-translations" class="nav-link">
  更多翻译
</a></li></ul></div></div> <a href="https://github.com/vuejs/docs-next-zh-cn" target="_blank" rel="noopener noreferrer" class="repo-link">
    GitHub
    <span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></nav>  <ul class="sidebar-links"><li><a href="/vue3/api/application-config.html" aria-current="page" class="active sidebar-link">应用配置</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/vue3/api/application-config.html#errorhandler" class="sidebar-link">errorHandler</a></li><li class="sidebar-sub-header"><a href="/vue3/api/application-config.html#warnhandler" class="sidebar-link">warnHandler</a></li><li class="sidebar-sub-header"><a href="/vue3/api/application-config.html#globalproperties" class="sidebar-link">globalProperties</a></li><li class="sidebar-sub-header"><a href="/vue3/api/application-config.html#optionmergestrategies" class="sidebar-link">optionMergeStrategies</a></li><li class="sidebar-sub-header"><a href="/vue3/api/application-config.html#performance" class="sidebar-link">performance</a></li><li class="sidebar-sub-header"><a href="/vue3/api/application-config.html#compileroptions" class="sidebar-link">compilerOptions</a><ul class="sidebar-sub-headers"><li class="sidebar-sub-header"><a href="/vue3/api/application-config.html#compileroptions-iscustomelement" class="sidebar-link">compilerOptions.isCustomElement</a></li><li class="sidebar-sub-header"><a href="/vue3/api/application-config.html#compileroptions-whitespace" class="sidebar-link">compilerOptions.whitespace</a></li><li class="sidebar-sub-header"><a href="/vue3/api/application-config.html#compileroptions-delimiters" class="sidebar-link">compilerOptions.delimiters</a></li><li class="sidebar-sub-header"><a href="/vue3/api/application-config.html#compileroptions-comments" class="sidebar-link">compilerOptions.comments</a></li></ul></li><li class="sidebar-sub-header"><a href="/vue3/api/application-config.html#iscustomelement" class="sidebar-link">isCustomElement</a></li></ul></li><li><a href="/vue3/api/application-api.html" class="sidebar-link">应用 API</a></li><li><a href="/vue3/api/global-api.html" class="sidebar-link">全局 API</a></li><li><section class="sidebar-group depth-0"><a href="/vue3/api/options-api" class="sidebar-heading clickable"><span>选项</span> <!----></a> <ul class="sidebar-links sidebar-group-items"><li><a href="/vue3/api/options-data.html" class="sidebar-link">Data</a></li><li><a href="/vue3/api/options-dom.html" class="sidebar-link">DOM</a></li><li><a href="/vue3/api/options-lifecycle-hooks.html" class="sidebar-link">生命周期钩子</a></li><li><a href="/vue3/api/options-assets.html" class="sidebar-link">选项/资源</a></li><li><a href="/vue3/api/options-composition.html" class="sidebar-link">组合</a></li><li><a href="/vue3/api/options-misc.html" class="sidebar-link">杂项</a></li></ul></section></li><li><a href="/vue3/api/instance-properties.html" class="sidebar-link">实例 property</a></li><li><a href="/vue3/api/instance-methods.html" class="sidebar-link">实例方法</a></li><li><a href="/vue3/api/directives.html" class="sidebar-link">指令</a></li><li><a href="/vue3/api/special-attributes.html" class="sidebar-link">特殊 attribute</a></li><li><a href="/vue3/api/built-in-components.html" class="sidebar-link">内置组件</a></li><li><section class="sidebar-group depth-0"><a href="/vue3/api/reactivity-api" class="sidebar-heading clickable"><span>响应性 API</span> <!----></a> <ul class="sidebar-links sidebar-group-items"><li><a href="/vue3/api/basic-reactivity.html" class="sidebar-link">响应性基础 API</a></li><li><a href="/vue3/api/refs-api.html" class="sidebar-link">Refs</a></li><li><a href="/vue3/api/computed-watch-api.html" class="sidebar-link">Computed 与 watch</a></li><li><a href="/vue3/api/effect-scope.html" class="sidebar-link">Effect 作用域 API</a></li></ul></section></li><li><a href="/vue3/api/composition-api.html" class="sidebar-link">组合式 API</a></li><li><section class="sidebar-group depth-0"><p class="sidebar-heading"><span>单文件组件</span> <!----></p> <ul class="sidebar-links sidebar-group-items"><li><a href="/vue3/api/sfc-spec.html" class="sidebar-link">规范</a></li><li><a href="/vue3/api/sfc-tooling.html" class="sidebar-link">工具</a></li><li><a href="/vue3/api/sfc-script-setup.html" class="sidebar-link">&lt;script setup&gt;</a></li><li><a href="/vue3/api/sfc-style.html" class="sidebar-link">&lt;style&gt; 特性</a></li></ul></section></li></ul> </aside> <main class="page"><div class="carbon-ads"></div>  <div class="theme-default-content content__default"><h1 id="应用配置"><a href="#应用配置" class="header-anchor">#</a> 应用配置</h1> <p>每个 Vue 应用都会暴露一个 <code>config</code> 对象，该对象包含此应用的配置设置：</p> <div class="language-js line-numbers-mode"><pre class="language-js"><code><span class="token keyword">const</span> app <span class="token operator">=</span> <span class="token function">createApp</span><span class="token punctuation">(</span><span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">)</span>

console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span>app<span class="token punctuation">.</span>config<span class="token punctuation">)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>在挂载应用之前，你可以修改其 property，如下所示。</p> <h2 id="errorhandler"><a href="#errorhandler" class="header-anchor">#</a> errorHandler</h2> <ul><li><p><strong>类型</strong>：<code>Function</code></p></li> <li><p><strong>默认</strong>：<code>undefined</code></p></li> <li><p><strong>用法</strong>：</p></li></ul> <div class="language-js line-numbers-mode"><pre class="language-js"><code>app<span class="token punctuation">.</span>config<span class="token punctuation">.</span><span class="token function-variable function">errorHandler</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token parameter">err<span class="token punctuation">,</span> vm<span class="token punctuation">,</span> info</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
  <span class="token comment">// 处理错误</span>
  <span class="token comment">// `info` 是 Vue 特定的错误信息，比如错误所在的生命周期钩子</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br></div></div><p>指定一个处理函数，来处理组件渲染方法和侦听器执行期间抛出的未捕获错误。这个处理函数被调用时，可获取错误信息和应用实例。</p> <blockquote><p>错误追踪服务 <a href="https://sentry.io/for/vue/" target="_blank" rel="noopener noreferrer">Sentry<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> 和 <a href="https://docs.bugsnag.com/platforms/browsers/vue/" target="_blank" rel="noopener noreferrer">Bugsnag<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> 使用此选项提供官方集成。</p></blockquote> <h2 id="warnhandler"><a href="#warnhandler" class="header-anchor">#</a> warnHandler</h2> <ul><li><p><strong>类型</strong>：<code>Function</code></p></li> <li><p><strong>默认</strong>：<code>undefined</code></p></li> <li><p><strong>用法</strong>：</p></li></ul> <div class="language-js line-numbers-mode"><pre class="language-js"><code>app<span class="token punctuation">.</span>config<span class="token punctuation">.</span><span class="token function-variable function">warnHandler</span> <span class="token operator">=</span> <span class="token keyword">function</span><span class="token punctuation">(</span><span class="token parameter">msg<span class="token punctuation">,</span> vm<span class="token punctuation">,</span> trace</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
  <span class="token comment">// `trace` 是组件的继承关系追踪</span>
<span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br></div></div><p>为 Vue 的运行时警告指定一个自定义处理函数。注意这只会在开发环境下生效，在生产环境下它会被忽略。</p> <h2 id="globalproperties"><a href="#globalproperties" class="header-anchor">#</a> globalProperties</h2> <ul><li><p><strong>类型</strong>：<code>[key: string]: any</code></p></li> <li><p><strong>默认</strong>：<code>undefined</code></p></li> <li><p><strong>用法</strong>：</p></li></ul> <div class="language-js line-numbers-mode"><pre class="language-js"><code>app<span class="token punctuation">.</span>config<span class="token punctuation">.</span>globalProperties<span class="token punctuation">.</span>foo <span class="token operator">=</span> <span class="token string">'bar'</span>

app<span class="token punctuation">.</span><span class="token function">component</span><span class="token punctuation">(</span><span class="token string">'child-component'</span><span class="token punctuation">,</span> <span class="token punctuation">{</span>
  <span class="token function">mounted</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>foo<span class="token punctuation">)</span> <span class="token comment">// 'bar'</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br></div></div><p>添加一个可以在应用的任何组件实例中访问的全局 property。组件的 property 在命名冲突具有优先权。</p> <p>这可以代替 Vue 2.x <code>Vue.prototype</code> 扩展：</p> <div class="language-js line-numbers-mode"><pre class="language-js"><code><span class="token comment">// 之前(Vue 2.x)</span>
<span class="token class-name">Vue</span><span class="token punctuation">.</span>prototype<span class="token punctuation">.</span><span class="token function-variable function">$http</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span><span class="token punctuation">}</span>

<span class="token comment">// 之后(Vue 3.x)</span>
<span class="token keyword">const</span> app <span class="token operator">=</span> <span class="token function">createApp</span><span class="token punctuation">(</span><span class="token punctuation">{</span><span class="token punctuation">}</span><span class="token punctuation">)</span>
app<span class="token punctuation">.</span>config<span class="token punctuation">.</span>globalProperties<span class="token punctuation">.</span><span class="token function-variable function">$http</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span><span class="token punctuation">}</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br></div></div><h2 id="optionmergestrategies"><a href="#optionmergestrategies" class="header-anchor">#</a> optionMergeStrategies</h2> <ul><li><p><strong>类型</strong>：<code>{ [key: string]: Function }</code></p></li> <li><p><strong>默认</strong>：<code>{}</code></p></li> <li><p><strong>用法</strong>：</p></li></ul> <div class="language-js line-numbers-mode"><pre class="language-js"><code><span class="token keyword">const</span> app <span class="token operator">=</span> <span class="token function">createApp</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
  <span class="token function">mounted</span><span class="token punctuation">(</span><span class="token punctuation">)</span> <span class="token punctuation">{</span>
    console<span class="token punctuation">.</span><span class="token function">log</span><span class="token punctuation">(</span><span class="token keyword">this</span><span class="token punctuation">.</span>$options<span class="token punctuation">.</span>hello<span class="token punctuation">)</span>
  <span class="token punctuation">}</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span>

app<span class="token punctuation">.</span>config<span class="token punctuation">.</span>optionMergeStrategies<span class="token punctuation">.</span><span class="token function-variable function">hello</span> <span class="token operator">=</span> <span class="token punctuation">(</span><span class="token parameter">parent<span class="token punctuation">,</span> child</span><span class="token punctuation">)</span> <span class="token operator">=&gt;</span> <span class="token punctuation">{</span>
  <span class="token keyword">return</span> <span class="token template-string"><span class="token template-punctuation string">`</span><span class="token string">Hello, </span><span class="token interpolation"><span class="token interpolation-punctuation punctuation">${</span>child<span class="token interpolation-punctuation punctuation">}</span></span><span class="token template-punctuation string">`</span></span>
<span class="token punctuation">}</span>

app<span class="token punctuation">.</span><span class="token function">mixin</span><span class="token punctuation">(</span><span class="token punctuation">{</span>
  hello<span class="token operator">:</span> <span class="token string">'Vue'</span>
<span class="token punctuation">}</span><span class="token punctuation">)</span>

<span class="token comment">// 'Hello, Vue'</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br><span class="line-number">3</span><br><span class="line-number">4</span><br><span class="line-number">5</span><br><span class="line-number">6</span><br><span class="line-number">7</span><br><span class="line-number">8</span><br><span class="line-number">9</span><br><span class="line-number">10</span><br><span class="line-number">11</span><br><span class="line-number">12</span><br><span class="line-number">13</span><br><span class="line-number">14</span><br><span class="line-number">15</span><br></div></div><p>为自定义选项定义合并策略。</p> <p>合并策略选项分别接收在父实例和子实例上定义的选项的值作为第一个和第二个参数。</p> <ul><li><strong>参考</strong>：<a href="/vue3/guide/mixins.html#自定义选项合并策略">自定义选项合并策略</a></li></ul> <h2 id="performance"><a href="#performance" class="header-anchor">#</a> performance</h2> <ul><li><p><strong>类型</strong>：<code>boolean</code></p></li> <li><p><strong>默认</strong>：<code>false</code></p></li> <li><p><strong>用法</strong>：</p></li></ul> <p>设置为 <code>true</code> 以在浏览器开发工具的 performance/timeline 面板中启用对组件初始化、编译、渲染和更新的性能追踪。只适用于开发模式和支持 <a href="https://developer.mozilla.org/en-US/docs/Web/API/Performance/mark" target="_blank" rel="noopener noreferrer">performance.mark<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a> API 的浏览器。</p> <h2 id="compileroptions"><a href="#compileroptions" class="header-anchor">#</a> compilerOptions <span class="badge tip" style="vertical-align:top;" data-v-0cc74adb>3.1+</span></h2> <ul><li><strong>类型</strong>：<code>Object</code></li></ul> <p>配置运行时编译器的选项。设置在这个对象上的值将会被传入浏览器内的模板编译器，并影响配置过的应用内的每个组件。注意，你也可以使用 <a href="/vue3/api/options-misc.html#compileroptions"><code>compilerOptions</code> 选项</a>在每个组件的基础上覆写这些选项。</p> <div class="custom-block tip"><p class="custom-block-title">重要</p> <p>该配置选项只在完整的构建版本中生效 (例如可以在浏览器中编译模板的独立版 <code>vue.js</code>)。如果你使用的是附带额外构建设置的仅运行时版本，编译器选项必须传入 <code>@vue/compiler-dom</code> 构建工具的配置来替代</p> <ul><li><p>对 <code>vue-loader</code> 来说：<a href="https://vue-loader.vuejs.org/options.html#compileroptions" target="_blank" rel="noopener noreferrer">通过 <code>compilerOptions</code> loader 选项传入<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>。也可以查阅 <a href="https://cli.vuejs.org/zh/guide/webpack.html#%E4%BF%AE%E6%94%B9-loader-%E9%80%89%E9%A1%B9" target="_blank" rel="noopener noreferrer"><code>vue-cli</code> 中的配置方式<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>。</p></li> <li><p>对 <code>vite</code> 来说：<a href="https://github.com/vitejs/vite/tree/main/packages/plugin-vue#example-for-passing-options-to-vuecompiler-dom" target="_blank" rel="noopener noreferrer">通过 <code>@vitejs/plugin-vue</code> 选项传入<span><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a>。</p></li></ul></div> <h3 id="compileroptions-iscustomelement"><a href="#compileroptions-iscustomelement" class="header-anchor">#</a> compilerOptions.isCustomElement</h3> <ul><li><p><strong>类型</strong>：<code>(tag: string) =&gt; boolean</code></p></li> <li><p><strong>默认值</strong>：<code>undefined</code></p></li> <li><p><strong>用法</strong>：</p></li></ul> <div class="language-js line-numbers-mode"><pre class="language-js"><code><span class="token comment">// 任何 'ion-' 开头的元素都会被识别为自定义元素</span>
app<span class="token punctuation">.</span>config<span class="token punctuation">.</span>compilerOptions<span class="token punctuation">.</span><span class="token function-variable function">isCustomElement</span> <span class="token operator">=</span> <span class="token parameter">tag</span> <span class="token operator">=&gt;</span> tag<span class="token punctuation">.</span><span class="token function">startsWith</span><span class="token punctuation">(</span><span class="token string">'ion-'</span><span class="token punctuation">)</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>指定一个方法来识别 Vue 以外 (例如通过 Web Components API) 定义的自定义元素。如果组件匹配了这个条件，就不需要本地或全局注册，Vue 也不会抛出 <code>Unknown custom element</code> 的警告。</p> <blockquote><p>注意所有的原生 HTML 和 SVG 标记不需要被这个函数匹配——Vue 的解析器会自动检测它们。</p></blockquote> <h3 id="compileroptions-whitespace"><a href="#compileroptions-whitespace" class="header-anchor">#</a> compilerOptions.whitespace</h3> <ul><li><p><strong>类型</strong>：<code>'condense' | 'preserve'</code></p></li> <li><p><strong>默认值</strong>：<code>'condense'</code></p></li> <li><p><strong>用法</strong>：</p></li></ul> <div class="language-js line-numbers-mode"><pre class="language-js"><code>app<span class="token punctuation">.</span>config<span class="token punctuation">.</span>compilerOptions<span class="token punctuation">.</span>whitespace <span class="token operator">=</span> <span class="token string">'preserve'</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>默认情况下，Vue 会移除/压缩模板元素之间的空格以产生更高效的编译结果：</p> <ol><li>元素内的多个开头/结尾空格会被压缩成一个空格</li> <li>元素之间的包括折行在内的多个空格会被移除</li> <li>文本结点之间可被压缩的空格都会被压缩成为一个空格</li></ol> <p>设置 <code>'preserve'</code> 的值可以禁用 (2) 和 (3)。</p> <h3 id="compileroptions-delimiters"><a href="#compileroptions-delimiters" class="header-anchor">#</a> compilerOptions.delimiters</h3> <ul><li><p><strong>类型</strong>：<code>Array&lt;string&gt;</code></p></li> <li><p><strong>默认值</strong>：<code>['{{', '}}']</code></p></li> <li><p><strong>用法</strong>：</p></li></ul> <div class="language-js line-numbers-mode"><pre class="language-js"><code><span class="token comment">// 将边界符改变为 ES6 模板字符串风格</span>
app<span class="token punctuation">.</span>config<span class="token punctuation">.</span>compilerOptions<span class="token punctuation">.</span>delimiters <span class="token operator">=</span> <span class="token punctuation">[</span><span class="token string">'${'</span><span class="token punctuation">,</span> <span class="token string">'}'</span><span class="token punctuation">]</span>    
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br><span class="line-number">2</span><br></div></div><p>设置用在模板内的文本插值的边界符。</p> <p>这个选项一般会用于避免和同样使用大括号语法的服务端框架发生冲突。</p> <h3 id="compileroptions-comments"><a href="#compileroptions-comments" class="header-anchor">#</a> compilerOptions.comments</h3> <ul><li><p><strong>类型</strong>：<code>boolean</code></p></li> <li><p><strong>默认值</strong>：<code>false</code></p></li> <li><p><strong>用法</strong>：</p></li></ul> <div class="language-js line-numbers-mode"><pre class="language-js"><code>app<span class="token punctuation">.</span>config<span class="token punctuation">.</span>compilerOptions<span class="token punctuation">.</span>comments <span class="token operator">=</span> <span class="token boolean">true</span>
</code></pre> <div class="line-numbers-wrapper"><span class="line-number">1</span><br></div></div><p>默认情况下，Vue 会在生产环境下移除模板内的 HTML 注释。将这个选项设置为 <code>true</code> 可以强制 Vue 在生产环境下保留注释。而在开发环境下注释是始终被保留的。</p> <p>这个选项一般会用于依赖 HTML 注释的其它库和 Vue 配合使用。</p> <h2 id="iscustomelement"><a href="#iscustomelement" class="header-anchor">#</a> isCustomElement <span class="badge warning" style="vertical-align:top;" data-v-0cc74adb>deprecated</span></h2> <p>从 3.1.0 开始被废弃。请换用 <a href="#compileroptions-iscustomelement"><code>compilerOptions.isCustomElement</code></a>。</p></div> <footer class="page-edit" data-v-007274aa><div class="container" data-v-007274aa><p data-v-007274aa><span class="edit-link" data-v-007274aa>
         发现了错误或者想要为文档做贡献？
          <a href="https://github.com/vuejs/docs-next-zh-cn/edit/master/src/api/application-config.md" target="_blank" rel="noopener noreferrer" data-v-007274aa>
            在 GitHub 上编辑此页
            <span data-v-007274aa><svg xmlns="http://www.w3.org/2000/svg" aria-hidden="true" focusable="false" x="0px" y="0px" viewBox="0 0 100 100" width="15" height="15" class="icon outbound"><path fill="currentColor" d="M18.8,85.1h56l0,0c2.2,0,4-1.8,4-4v-32h-8v28h-48v-48h28v-8h-32l0,0c-2.2,0-4,1.8-4,4v56C14.8,83.3,16.6,85.1,18.8,85.1z"></path> <polygon fill="currentColor" points="45.7,48.7 51.3,54.3 77.2,28.5 77.2,37.2 85.2,37.2 85.2,14.9 62.8,14.9 62.8,22.9 71.5,22.9"></polygon></svg> <span class="sr-only">(opens new window)</span></span></a></span> <!----></p></div></footer> <div class="page-nav"><p class="inner"><!----> <span class="next"><a href="/vue3/api/application-api.html">应用 API</a>
      →
    </span></p></div> <div class="bsa-cpc-wrapper"><div class="bsa-cpc"></div></div> </main></div><div class="global-ui"><!----></div></div>
    <script src="/vue3/assets/js/app.9f011487.js" defer></script><script src="/vue3/assets/js/11.bea13863.js" defer></script><script src="/vue3/assets/js/43.98898a3b.js" defer></script><script src="/vue3/assets/js/32.75be14cd.js" defer></script><script src="/vue3/assets/js/23.f23a1976.js" defer></script>
  </body>
</html>
